package com.woniuxy.woniuticket.searchmodule.controller;


import com.woniuxy.woniuticket.pojo.CinemaMovies;
import com.woniuxy.woniuticket.searchmodule.dto.SearchDto;
import com.woniuxy.woniuticket.searchmodule.service.SearchService;
import com.woniuxy.woniuticket.searchmodule.util.SearchParameterUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.web.PageableDefault;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.data.domain.Pageable;
import java.util.List;

/*
* 搜索管理层
* */
@CrossOrigin
@RestController
@RequestMapping("/sear")
public class SearchController {
    @Autowired
    private SearchService searchService;
    /*显示商品*/
    @RequestMapping("/moveis")
    @ResponseBody
    public ResponseEntity<SearchDto> searMovies(SearchParameterUtil searchParameterUtil){
        String key = searchParameterUtil.getKey();
        System.out.println(key+"进来了");
        SearchDto searchDto = this.searchService.searchMovie(searchParameterUtil);
        if (searchDto==null){
            return new ResponseEntity<>(HttpStatus.NOT_FOUND);
        }
        return ResponseEntity.ok(searchDto);
    }
    /*搜索商品*/
    @RequestMapping("/showmovies")
    @ResponseBody
    public ResponseEntity<List<CinemaMovies>> searMovies(){
        List<CinemaMovies> cinemaMoviesList = searchService.showSer();
        System.out.println(cinemaMoviesList.toString());
        return ResponseEntity.ok(cinemaMoviesList);
    }

}
